const mongoose = require('mongoose');
const articleSchema = new mongoose.Schema({
    title: {
        type: String,
        minlength: 4,
        maxlength: 40,
        required: [true, '文章标题不符合规则']
    },
    author: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Users',
        required: [true, '请传递作者']
    },
    publishDate: {
        type: Date,
        default: Date.now
    },
    cover: {
        type: String,
        default: null
    },
    content: {
        type: String
    }
})
const Article = mongoose.model('Article', articleSchema)
module.exports = { Article };